package com.example.daiyinuo.composite.component;

public class TestComposite {
    public static void main(String[] args) {
        //构建总部
        OrganizationComposite head = new OrganizationComposite("总公司");
        AdminDepartment headAdmin = new AdminDepartment("总公司行政部");
        ItDepetment headIt = new ItDepetment("总公司IT部门");
        head.add(headAdmin);
        head.add(headIt);
        //构建分公司
        OrganizationComposite branch = new OrganizationComposite("上海分公司");
        AdminDepartment branchAdmin = new AdminDepartment("上海分公司行政部");
        ItDepetment branchIt = new ItDepetment("上海分公司IT部门");
        branch.add(branchAdmin);
        branch.add(branchIt);
        //将分公司加入总公司
        head.add(branch);

        System.out.println(String.format("%s共有%d名员工",head.getName(),head.getStaffCount()));
        OrganizationComponent branchCom = head.getChild("上海分公司");
        System.out.println(String.format("%s共有%d名员工",branch.getName(),branch.getStaffCount()));
    }
}
